package gregorytersoff_model;

public class Edge 
{
	private int line1;
	private int line2;
	private int height;
	
	/**
	 * Edges store the two lines they connect, and the height they connect at, in order to keep track of the graphical representation and to
	 * determine the final result
	 * @param l1 One of the lines (the left of the two unless an edge is deliberately created in code to store otherwise) the edge connects
	 * @param l2 One of the lines (the right of the two unless an edge is deliberately created in code to store otherwise) the edge connects
	 * @param h The height of the edge
	 */
	public Edge(int l1, int l2, int h)
	{
		line1 = l1;
		line2 = l2;
		height = h;
	}
	/**Allows access to the height of the edge
	 * 
	 * @return The height of the edge
	 */
	public int getHeight()
	{
		return height;
	}
	/**Allows access to the first of the two lines
	 * 
	 * @return The height of the first of the two lines
	 */
	public int getLine1()
	{
		return line1;
	}

	/**Allows access to the second of the two lines
	 * 
	 * @return The height of the second of the two lines
	 */
	public int getLine2()
	{
		return line2;
	}
	/**Takes in the current position of the line, and checks if it matches either of the two lines this edge connects. If it does, it returns
	 * the other line (signaling that the path crosses at this point) and if not, it returns the input position (signaling that this edge does
	 * not effect the path currently being traced)
	 * 
	 * @param starting The position of the line calling this method from this edge
	 * @return The position of the line after it passes through this height
	 */
	public int checkLines(int starting)
	{
		if(line1 == starting)
			return line2;
		if(line2 == starting)
			return line1;
		return starting;
	}
}
